import influxdb
from clientUtil import devClient, sitClient, uatClient


# 创建 InfluxDB 客户端
client = uatClient()

# data = [
#     {
#         'measurement': 'cpu_usage',
#         'tags': {'host': 'server1'},
#         'fields': {'value': 0.5}
#     },
#     {
#         'measurement': 'cpu_usage',
#         'tags': {'host': 'server2'},
#         'fields': {'value': 0.7}
#     }
#
#
# ]
# 写入数据
# client.write_points(data)

# # 查询数据
# query = (" select count(*) from ActValWbl1 where equipmentAcode = '虚拟设备4'  "
#          " and time >= '2025-04-09T00:00:00.000000Z'  and time <= '2025-04-09T10:50:17.000000Z'  "
#          " and consigner =~ /.*ex_dengcc2.*/  and testFormNumber =~ /.*ST2024070052.*/ ")
#
# query = (" select ESTIMATED_COUNT(*) from ActValWbl2 where equipmentAcode = '虚拟设备4'  "
#          " and time >= '2025-04-09T00:00:00.000000Z'  and time <= '2025-04-10T10:50:17.000000Z'  ")
# 删除掉表

query = (" DROP MEASUREMENT ActValYsj27 ")
result = client.query(query)

# 获取查询结果的列表数据
data_list = list(result.get_points())


# 遍历列表数据
for index,data in enumerate(data_list):
    print(f"索引值：{index}-----------------------------")
    # 循环键值对
    for index,(key, value) in enumerate(data.items()):
        print(f"索引值：{index}, 键：{key}, 值：{value}")

# 关闭客户端
client.close()
